<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>form</title>
    <script type="text/javascript" src="./jquery-3.3.1.js"></script>
    <script type="text/javascript">
        window.onload=function(){
            var ouser=document.getElementById('user');
            var opass=document.getElementById('pass');
            var obtn=document.getElementById('btn');

            obtn.onclick=function(){               
                $.get(
                    "/login",
                    {user:ouser.value,pass:opass.value},
                    function(str){
                        // alert(JSON.stringify(str));
                        // var json=eval('('+str+')');
                        if(str.ok){
                            alert('登录成功！');
                        }else{
                            alert('登录失败……'+str.msg);
                        }
                    },
                    "json"
                );
            };
        };
    </script>
    
</head>
<body>
    用户：<input type="text" id="user" /><br>
    密码：<input type="password" id="pass" /><br>
        <input type="button" id="btn" /><br>
</body>
</html>